#include <iostream>
#include <string>
#include <stack>

int main() {
    std::string a;
    std::getline(std::cin, a);
    char z[] = {'(', '[', '{', '<'};
    char x[] = {')', ']', '}', '>'};
    int c[] = {0, 0, 0, 0};
    std::stack<char> s;
    bool flag = true;
    for (size_t i = 0; i < a.length(); ++i) {
        for (int k = 0; k < 4; ++k) {
            if (a[i] == z[k]) {
                c[k]++;
                s.push(z[k]);
                break;
            } else if (a[i] == x[k]) {
                c[k]--;
                if (s.empty()) {
                    continue;
                }
                if (s.top() == z[k]) {
                    s.pop();
                } else {
                    flag = false;
                }
                break;
            }
        }
        for (int j = 0; j < 4; ++j) {
            if (c[j] < 0) {
                flag = false;
                break;
            }
        }
    }
    if (!s.empty()) {
        flag = false;
    }
    if (flag) {
        std::cout << "True" << std::endl;
    } else {
        std::cout << "False" << std::endl;
    }
    return 0;
}

